var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var session = require('express-session');

var app = express();




var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
var soapRouter = require('./routes/soaptest');
var loginRouter = require('./routes/login');
app.set('views',path.join(__dirname, 'views'));
app.set('view engine', 'html');
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({extended: false}));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'node_modules')));
app.use('/index', indexRouter);
app.use('/users', usersRouter);
app.use('/login', loginRouter);
app.use('/soapiest', soapRouter);
app.use('/', loginRouter);


app.use(cookieParser('xxx'));
app.use(session({
    secret: 'xxx',
    resave: true,
    saveUninitialized: true,
    cookie: {
        maxAge: 1000 * 60 * 60 * 24   //有效期一天

    }
}));

module.exports = app;
